import request from '@/utils/request'
import axios from 'axios'

export function listiorderStocks(data) {
  return request({
    url: '/iorderStock/list',
    method: 'post',
    data
  })
}

export function getStockBatchNumbers(query) {
  return request({
    url: '/iorderStock/getBachNumber',
    method: 'get',
    params: query
  })
}


export function getLastTwoChars(str) {
  return str.slice(-2);
}

export function getStocks2(query) {
  return request({
    url: '/iorderStock/listSelectBatchNumber',
    method: 'get',
    params: query
  });
}


export function listiorderStocks2(data) {
  return request({
    url: '/iorderStock/list2',
    method: 'post',
    data
  })
}
export function getOneId(id) {
  return request({
    url: '/iorderStock/getOneById',
    method: 'get',
    params: { id }
  })
}


export function editStock(query) {
  return request({
    url: '/iorderStock/editStock',
    method: 'get',
    params: query
  })
}

export function listiorderStocks3(query) {
  return request({
    url: '/iorder/getStock',
    method: 'post',
    params: query
  })
}
/*export function listiorderStocks(query) {
  return request({
    url: '/iorderStock/list',
    method: 'get',
    params: query
  })
}*/


export function showStock(query) {
  return request({
    url: '/iorderStock/list',
    method: 'get',
    params: query
  })
}




export function rollbackStock(query) {
  return request({
    url: '/iorderStock/rollbackStock',
    method: 'get',
    params: query
  })
}

export function deleteIorderStocks(data) {
  return request({
    url: '/iorderStock/deleteiorderStock',
    method: 'post',
    data
  })
}

export const uploadFileRequest = (url, params) => {
  return axios({
    method: 'post',
    url: '/iorderStock/insertMany',
    data: params,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function publishiorderStock(query) {
  return request({
    url: '/iorderStock/publishiorderStock',
    method: 'get',
    params:query
  })
}


export function detailiorderStock(id) {
  return request({
    url: '/iorderStock/detail',
    method: 'get',
    params: { id }
  })
}

export function detailproductInfo(data) {
  return request({
    url: '/iorder/queryProduction',
    method: 'post',
    data
  })
}

export function detailCF(data) {
  return request({
    url: '/iorder/queryCF',
    method: 'post',
    data
  })
}

export function createOrderList(data) {
  return request({
    url: '/iorder/queryListCount',
    method: 'post',
    data
  })
}

export function createStock(data) {
  return request({
    url: '/iorder/createStock',
    method: 'post',
    data
  })
}

export function catchTotalInfo(data) {
  return request({
    url: '/iorder/getTotalSheet',
    method: 'post',
    data
  })
}

export function createShipAccord(data) {
  return request({
    url: '/iorder/getShipAccord',
    method: 'post',
    data
  })
}

export function getOAsheet(data) {
  return request({
    url: '/iorder/getOAsheet',
    method: 'post',
    data
  })
}


export function getSplitSheet(data) {
  return request({
    url: '/iorder/getSplitSheet',
    method: 'post',
    data
  })
}


export function getSplitSheet2(data) {
  return request({
    url: '/iorder/getSplitSheet2',
    method: 'post',
    data
  })
}


export function editiorderStock(data) {
  return request({
    url: '/iorderStock/update',
    method: 'post',
    data
  })
}
export function moreiorderStock(data) {
  return request({
    url: '/iorderStock/more',
    method: 'post',
    data
  })
}

export function listCatAndBrand() {
  return request({
    url: '/iorderStock/catAndBrand',
    method: 'get'
  })
}

export function myformatdate(inputTime) {
  if (!inputTime && typeof inputTime !== 'number') {
    return ''
  }
  var localTime = ''
  inputTime = new Date(inputTime).getTime()
  const offset = (new Date()).getTimezoneOffset()
  localTime = (new Date(inputTime - offset * 60000)).toISOString()
  localTime = localTime.substr(0, localTime.lastIndexOf('.'))
  localTime = localTime.replace('T', ' ')
  return localTime
}
export function formatterTime(row, column) {
  const data = row[column.property]
  return /\d{4}-\d{1,2}-\d{1,2}/g.exec(data)
}

